package cn.tedu.waimai.controller;

import cn.tedu.waimai.entity.Admin;
import cn.tedu.waimai.mapper.AdminMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AdminController {
@Autowired
    AdminMapper mapper;
@RequestMapping("/Admin_insert")
    public String Admininsert(Admin admin){
    System.out.println(admin);
    if (admin.getAdmin_name().isEmpty()||admin.getAdmin_password().isEmpty()){
        return "账户或密码为空";
    }
    mapper.Admin_insert(admin);
    return "账号已加入管理员";
}

//登陆
@RequestMapping("/selectByAdmin_name")
    public String selectByAdmin_name(Admin admin){

    Admin a=mapper.selectByAdmin_name(admin.getAdmin_name());
if (a!=null){
    if (admin.getAdmin_password().equals(a.getAdmin_password())){
        return "登陆成功";
    }
    return "密码错误";
}
return "账号不存在";
}

}
